<template>
  <navbar title="消息" :isBack="true"></navbar>
  <loading v-if="!list.length"></loading>
  <picture
    v-if="!list.length && page != 1"
    title="暂无消息"
    imgPath="/static/image/18.png"
    imgHeight="200rpx"
    imgWidth="360rpx"
    :height="tools.clientTopHight()"
  ></picture>
  <messList v-else :list="list"></messList>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { getNotice } from '@/service/api/index'
import { onLoad, onReachBottom } from '@dcloudio/uni-app'
import tools from '@/utils/tools'
import messList from '@/common/list/mess.vue'

let page = ref(1)
let list = ref([])

// 公告列表
const getNoticeApi = async () => {
  const { msg } = await getNotice({ page: page.value })
  if (!msg.data.length && page.value != 1) {
    return tools.showToast('暂无更多数据'), page.value--
  }
  list.value = [...list.value, ...msg.data]
  console.log(list.value)
}

onReachBottom(() => {
  page.value++
  getNoticeApi()
})

onLoad(() => {
  getNoticeApi()
})
</script>

<style lang="scss" scoped></style>
